package J20250227_dfs;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description: 地图——https://www.lanqiao.cn/problems/2930/learning/?page=2&first_category_id=1&tags=DFS&tag_relation=intersection
 * User: 王圆豪
 * Date: 2025-03-17
 * Time: 17:22
 */
public class Main7 {
    static int[] dx = {1,0};
    static int[] dy = {0,1};
    static long ret = 0;
    static char[][] arr;
    static int n,m;
    static int[][][][] memo;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        m = scan.nextInt();
        int k = scan.nextInt();
        scan.nextLine();
        arr = new char[n][m];
        for(int i = 0; i < n; i++){
            String s = scan.nextLine();
            for(int j = 0; j < m; j++){
                arr[i][j] = s.charAt(j);
                // System.out.print(arr[i][j]);
            }
            // System.out.println();
        }
        memo = new int[n+1][m+1][k+1][3];
        System.out.println(dfs(0,0,k,0,-1));
        scan.close();
    }

    public static long dfs(int x, int y, int k, int step,int tar){
        if(x==n-1 && y==m-1){
            return 1;
        }
        if(tar != -1 && memo[x][y][step][tar] != 0) return memo[x][y][step][tar];
        int num = 0;
        if(step == k) {
            if(tar==0 && x+1<n && arr[x+1][y]!='#') num+=dfs(x+1,y,k,step,tar);
            else if(tar == 1 && y+1<m && arr[x][y+1]!='#') num+=dfs(x,y+1,k,step,tar);
            return num;
        }
        for(int i = 0; i < 2; i++){
            int px = dx[i]+x, py = dy[i]+y;
            if(px>=0&&px<n&&py>=0&&py<m&&arr[px][py]!='#'){
                if(tar==-1 || i == tar)
                    num += dfs(px,py,k,step,i);
                else if(i != tar) num += dfs(px,py,k,step+1,i);
            }
        }
        if(tar != -1)memo[x][y][step][tar] = num;
        return num;
    }
}
